#include "./src/shared.h"
#include "./src/types.h"

// Deferred shader textures
samplerRect dsEC;

// Index into the light textures
uniform vec3 lightPos[LIGHTS_PER_PASS];

samplerRect prevImage;
uniform float lightScale;
uniform float lightSize;

void main (void)
{
	vec4 final;

	vec3 position = textureRect(dsEC, gl_FragCoord);

	for (int i=0; i<LIGHTS_PER_PASS; ++i) {
		vec3 lightPosition = lightPos[i];
		final += length(lightPosition - position) < lightSize ? 1.0  : 0.0; 
	}

	if (final.x) {
		gl_FragColor = final;
	} else {
		gl_FragColor = textureRect(prevImage, gl_FragCoord);
	}
}

